HNOBac Manuscript
  1. Methods
  2. Figures
  • Introduction
  • Methods
    • Cytokines
    • CFUs
    • LDH
    • RNASeq
    • Cell Counts
    • HekBlue Assays
    • Figures
  • References

Table of contents

  • File Paths
  • Figure assembling
    • Figure 1
    • Figure S1
    • Figure S2
    • Figure 2
  • Other code

Figures

File Paths

# Folder paths
Cyto_folder <- "data/outputs/Cytokines"
CFUs_figures_folder <- "data/outputs/CFUs/figures"
LDH_figures_folder <- "data/outputs/LDH/figures"
RNASeq_folder <- "data/outputs/RNASeq"
MOC_folder <- "data/outputs/MOC"
HekBlue_folder <- "data/outputs/HekBlue"

# Create subfolders for output files
figures_folder <- "data/outputs/Figures/Manuscript"
if (!file.exists("data/outputs/Figures/Manuscript")) {
  dir.create("data/outputs/Figures/Manuscript", recursive = TRUE)
}

# Load data and metadata
Heatmap <- readRDS(file.path(Cyto_folder, "figures_log2FC/heatmap.rds"))
Cyto_plots_list <- readRDS(file.path(Cyto_folder, "figures_pgml/plots_list.rds"))
Cyto_contrasts <- readRDS(file.path(Cyto_folder, "stats_pgml/stats_contrasts.rds"))
CFU_plot_34 <- readRDS(file.path(CFUs_figures_folder, "plotCFU_34.rds"))
LDH_plot_34 <- readRDS(file.path(LDH_figures_folder, "plotLDH_34C_48h.rds"))
CFU_plot_37 <- readRDS(file.path(CFUs_figures_folder, "plotCFU_37.rds"))
LDH_plot_37 <- readRDS(file.path(LDH_figures_folder, "plotLDH_37C_48h.rds"))
PCA_plot <- readRDS(file.path(RNASeq_folder, "plotPCA.rds"))
MOC_Cplot <- readRDS(file.path(MOC_folder, "boxplot_HNOCells.rds"))
HekBlue_A <- readRDS(file.path(HekBlue_folder, "plotHekBlue_Apical.rds"))
HekBlue_B <- readRDS(file.path(HekBlue_folder, "plotHekBlue_Basal.rds"))

Figure assembling

p.empty <-  ggplot() +
  theme_void() +
  theme(plot.margin = unit(c(0,0,0,0), "in"),
        plot.background = element_rect(fill = "white", color = "white"))

Figure 1

figure1_legend <- get_legend(LDH_plot_34 + 
                       theme(text = element_text(size = 12),
                             legend.key.size = unit(10,"pt"),
                             legend.key.spacing.y = unit(0, "pt"),
                             legend.spacing.y = unit(2, "pt"))
)
figure_1B <- CFU_plot_34 +
  theme(text = element_text(size = 12),
        plot.margin = unit(c(0.1, 0.1, 0.1, 0.1), "in"))

figure_1C <- LDH_plot_34 +
  theme(text = element_text(size = 12), 
        plot.margin = unit(c(0.1, 0.1, 0.1, 0.1), "in"),
        legend.position = "none")

figure_1 <- ggarrange(figure_1B, figure1_legend, figure_1C, nrow = 1, widths = c(1, 0.2, 0.6))
figure_1

# Save figure 
ggsave(plot = figure_1, filename = file.path(figures_folder, "figure_1.png"), width = unit(7.5, "in"), height = unit(3, "in"))
ggsave(plot = figure_1, filename = file.path(figures_folder, "figure_1.svg"), width = unit(7.5, "in"), height = unit(3, "in"))

Figure S1

figureS1_legendA <- get_legend(PCA_plot + 
                       theme(text = element_text(size = 14),
                             legend.key.size = unit(10,"pt"),
                             legend.key.spacing.y = unit(0, "pt"),
                             legend.spacing.y = unit(2, "pt"))
)

figureS1_legendB <- get_legend(LDH_plot_37 + 
                       theme(text = element_text(size = 14),
                             legend.key.size = unit(10,"pt"),
                             legend.key.spacing.y = unit(0, "pt"),
                             legend.spacing.y = unit(2, "pt"))
)
#figureS1_legend <- ggarrange(p.empty, figureS1_legendA, figureS1_legendB, p.empty, ncol = 1, heights = c(1, 0.2, 0.8, 1))
figureS1_legend <- ggarrange(p.empty, figureS1_legendA, figureS1_legendB, p.empty, ncol = 1, heights = c(0.2, 0.2, 0.8, 0.2))
figure_1SA <- PCA_plot +
  theme(text = element_text(size = 14), 
        plot.margin = unit(c(0.2, 0.2, 0.1, 0.1), "in"),
        legend.position = "none") 

figure_1SB <- MOC_Cplot +
  theme(text = element_text(size = 14), 
        plot.margin = unit(c(0.2, 0.1, 0.1, 0.05), "in"),
        legend.position = "none")

figure_1SC <- CFU_plot_37 +
  theme(text = element_text(size = 14),
        plot.margin = unit(c(0.2, 0.2, 0.1, 0.1), "in"))

figure_1SD <- LDH_plot_37 +
  theme(text = element_text(size = 14),
        plot.margin = unit(c(0.2, 0.1, 0.1, 0.1), "in"),
        legend.position = "none")

figure_1Sup <- ggarrange(figure_1SA, figure_1SB, figureS1_legend, labels = c("A", "B", ""), vjust = 1.3, nrow = 1, widths = c(1, 1, 0.4))
figure_1Sdown <- ggarrange(figure_1SC, figure_1SD, labels = c("C", "D"), vjust = 1.3, nrow = 1, widths = c(1, 0.6))

figure_1S <- ggarrange(figure_1Sup, figure_1Sdown, ncol = 1)
#figure_1S <- ggarrange(figureS1_legend, figure_1S, widths = c(0.2, 1))
figure_1S

# Save figure 
ggsave(plot = figure_1S, filename = file.path(figures_folder, "figure_S1.png"), width = unit(10.5, "in"), height = unit(8.5, "in"))
ggsave(plot = figure_1S, filename = file.path(figures_folder, "figure_S1.svg"), width = unit(10.5, "in"), height = unit(8.5, "in"))

Figure S2

figureS2_legend <- get_legend(HekBlue_A + 
                       theme(text = element_text(size = 14),
                             legend.key.size = unit(10,"pt"),
                             legend.key.spacing.y = unit(2, "pt"),
                             legend.spacing.y = unit(2, "pt"))
)
figure_2SB <- HekBlue_A +
  theme(text = element_text(size = 16),
        plot.margin = unit(c(-0.2, 0.1, 0.1, 0.1), "in"),
        legend.position = "none")

figure_2SC <- HekBlue_B +
  theme(text = element_text(size = 16), 
        plot.margin = unit(c(-0.2, 0.1, 0.1, 0.1), "in"),
        legend.position = "none")

figure_2SC <- ggarrange(figure_2SB, figure_2SC, figureS2_legend, nrow = 1, labels = c("B", "C", ""), widths = c(1, 1, 0.3), vjust = -1)
figure_2SC <- ggarrange(Heatmap, figure_2SC, ncol = 1, labels = c("A", ""))
figure_2SC

# Save figure 
ggsave(plot = figure_2SC, filename = file.path(figures_folder, "figure_S2.png"), width = unit(11, "in"), height = unit(8.5, "in"))
ggsave(plot = figure_2SC, filename = file.path(figures_folder, "figure_S2.svg"), width = unit(11, "in"), height = unit(8.5, "in"))

Figure 2

filter_plots <- function(list, contrasts, selected, ymin, ymax, rows, cols, widths) {
  sublist <- list() 
  plot_counter <- 1  # Initialize plot counter
  
  for (group in selected) {
    if (group == "LEGEND") {
        sublist <- c(sublist, list(figureS2_legend))  # Add the legend plot
        plot_counter <- plot_counter + 1  # Increment plot counter
      next  # Skip to the next group in the selected list
    }
    
    for (element in list) {
      if (element[[1]] == group) {
        # Change size of the geom_jitter for all plots
        element[[2]]$layers[[1]]$aes_params$size <- 1
        
        contrast_sign <- contrasts %>%
          filter(group_label == group) %>%
          filter(sign.FDR == TRUE & highlighted != "") %>%
          mutate(plot = "")
        
        # Extract the part of the string before the underscore for the plot title
        plot_title <- gsub("_.*$", "", group)
        
        # Common plot customizations
        plot_customization <- element[[2]] +
          theme(axis.ticks = element_blank(),
                axis.title.y = element_text(size = 12),
                legend.position = "none",
                text = element_text(size = 14),
                plot.title = element_text(size = 12))
        
        # Customization for plots on the last row
        if (plot_counter > (rows - 1) * cols) {
          plot_customization <- plot_customization +
            scale_x_discrete(labels = c("U", "", "Live", "", "", "Dead", "")) + 
            ggtitle(NULL) + 
            labs(y = "pg/mL (basal)") 
        } else {
          plot_customization <- plot_customization +
            scale_x_discrete(breaks = NULL, labels = NULL) +
            ggtitle(plot_title) + 
            labs(y = "pg/mL (apical)") 
        } 
        
        # Customization for plots on the first column
        if ((plot_counter - 1) %% cols == 0) {
          plot_customization <- plot_customization +
            scale_y_log10(limits = c(ymin, ymax),
                          breaks = trans_breaks("log10", function(x) 10^x),
                          labels = trans_format("log10", math_format(10^.x))) +
            theme(plot.margin = unit(c(0, 0.05, -0.1, 0.1), "in"))
        } else {
          plot_customization <- plot_customization +
            scale_y_log10(limits = c(ymin, ymax), breaks = NULL, labels = NULL) +
            labs(y = "") +
            theme(plot.margin = unit(c(0, 0.05, -0.1, -0.15), "in"))
        }
        
        # Conditionally add p-value annotations layer
        if (nrow(contrast_sign) > 0) {
          plot_customization <- plot_customization +
            stat_pvalue_manual(contrast_sign, label = "plot", y.position = log10(ymax) - 0.01, 
                               step.increase = -0.03, tip.length = 0, bracket.shorten = 0.2, vjust = 0.6)
        }
        
        # Add the customized plot to the sublist
        sublist <- c(sublist, list(plot_customization))
        
        plot_counter <- plot_counter + 1  # Increment plot counter
        break  # Exit the loop once the desired group is found
      }
    }
  }
  
  figure <- ggarrange(plotlist = sublist, nrow = rows, ncol = cols, widths = widths)
  
  return(figure)
}
groups_2A <- c("IL-1α_Apical", "IL-1RN_Apical", "IL-18_Apical", "IL-1α_Basal", "IL-1RN_Basal", "IL-18_Basal")
figure_2A <- filter_plots(Cyto_plots_list, Cyto_contrasts, groups_2A, ymin = 0.2, ymax = 10^4.25, rows = 2, cols = 3, widths = c(1.46, 1, 1))
figure_2A

groups_2B <- c("CXCL-10_Apical", "CXCL-11_Apical", "CXCL-10_Basal", "LEGEND")
figure_2B <- filter_plots(Cyto_plots_list, Cyto_contrasts, groups_2B, ymin = 0.5, ymax = 10^3.2, rows = 2, cols = 2, widths = c(1.46, 1))
figure_2B

groups_2C <- c("G-CSF_Apical", "CCL-20_Apical", "G-CSF_Basal", "CCL-20_Basal")
figure_2C <- filter_plots(Cyto_plots_list, Cyto_contrasts, groups_2C, ymin = 1, ymax = 10^5.5, rows = 2, cols = 2, widths = c(1.46, 1))
figure_2C

groups_2D <- c("TNF-α_Apical", "IL-6_Apical", "IL-8_Apical", "TNF-α_Basal", "IL-6_Basal", "IL-8_Basal")
figure_2D <- filter_plots(Cyto_plots_list, Cyto_contrasts, groups_2D, ymin = 0.25, ymax = 10^5, rows = 2, cols = 3, widths = c(1.46, 1, 1))
figure_2D

figure_2up <- ggarrange(figure_2A, figure_2B, labels = c("A", "B"), widths = c(2, 1.44), hjust = -1.3, vjust = 1.1)
figure_2up               

figure_2down <- ggarrange(figure_2C, figure_2D, labels = c("C", "D"), widths = c(1.44, 2), hjust = -1.3, vjust = 1.1)
figure_2down 

figure_2 <- ggarrange(p.empty, figure_2up, p.empty, figure_2down, nrow = 4, heights = c(0.02, 1, 0.01, 1))
figure_2

# Save figure 
ggsave(plot = figure_2, filename = file.path(figures_folder, "figure_2.png"), width = unit(7, "in"), height = unit(9, "in"))
ggsave(plot = figure_2, filename = file.path(figures_folder, "figure_2.svg"), width = unit(7, "in"), height = unit(9, "in"))

Other code

Code to make the legend from scratch

df_legend <- tibble(
  label = c(
    "<b><span style='color:#5b5b5b;'>Uncol</span></b>",
    "<b><i><span style='color:#0443DC;'>Dpi</span></i>",
    "<b><i><span style='color:#6D05A0;'>Sau</span></i>", 
    "<b><i><span style='color:#928AB9;'>Spn</span></i>"
  ),
  x = c(.1, .1, .1, .1),
  y = c(.4, .3, .2, .1),
  color = c("white", "white", "white", "white"),
  fill = c("white","white", "white", "white")
)

p.legend <-  ggplot(df_legend) +
  aes(x, y, label = label, color = color, fill = fill) +
  geom_textbox(width = unit(.8, "in")) +  
  scale_color_identity() +
  scale_fill_identity() +
  xlim(0, .2) + ylim(.1, .4) +
  theme_void() +
  theme(plot.margin = unit(c(0,-5,.2,-5), "in"),
        plot.background = element_rect(fill = "white", color = "white"))

p.legend
HekBlue Assays
References
Source Code
---
execute:
  message: FALSE
  warning: FALSE
---

# Figures {.unnumbered}

```{r}
#| eval: TRUE
#| echo: FALSE
#| message: FALSE
library(tidyverse)
library(ggpubr)
library(ggtext)
library(scales)
library(ggtext)
```

## File Paths

```{r}
# Folder paths
Cyto_folder <- "data/outputs/Cytokines"
CFUs_figures_folder <- "data/outputs/CFUs/figures"
LDH_figures_folder <- "data/outputs/LDH/figures"
RNASeq_folder <- "data/outputs/RNASeq"
MOC_folder <- "data/outputs/MOC"
HekBlue_folder <- "data/outputs/HekBlue"

# Create subfolders for output files
figures_folder <- "data/outputs/Figures/Manuscript"
if (!file.exists("data/outputs/Figures/Manuscript")) {
  dir.create("data/outputs/Figures/Manuscript", recursive = TRUE)
}

# Load data and metadata
Heatmap <- readRDS(file.path(Cyto_folder, "figures_log2FC/heatmap.rds"))
Cyto_plots_list <- readRDS(file.path(Cyto_folder, "figures_pgml/plots_list.rds"))
Cyto_contrasts <- readRDS(file.path(Cyto_folder, "stats_pgml/stats_contrasts.rds"))
CFU_plot_34 <- readRDS(file.path(CFUs_figures_folder, "plotCFU_34.rds"))
LDH_plot_34 <- readRDS(file.path(LDH_figures_folder, "plotLDH_34C_48h.rds"))
CFU_plot_37 <- readRDS(file.path(CFUs_figures_folder, "plotCFU_37.rds"))
LDH_plot_37 <- readRDS(file.path(LDH_figures_folder, "plotLDH_37C_48h.rds"))
PCA_plot <- readRDS(file.path(RNASeq_folder, "plotPCA.rds"))
MOC_Cplot <- readRDS(file.path(MOC_folder, "boxplot_HNOCells.rds"))
HekBlue_A <- readRDS(file.path(HekBlue_folder, "plotHekBlue_Apical.rds"))
HekBlue_B <- readRDS(file.path(HekBlue_folder, "plotHekBlue_Basal.rds"))
```

## Figure assembling 

```{r}
p.empty <-  ggplot() +
  theme_void() +
  theme(plot.margin = unit(c(0,0,0,0), "in"),
        plot.background = element_rect(fill = "white", color = "white"))
```

### Figure 1

```{r}
figure1_legend <- get_legend(LDH_plot_34 + 
                       theme(text = element_text(size = 12),
                             legend.key.size = unit(10,"pt"),
                             legend.key.spacing.y = unit(0, "pt"),
                             legend.spacing.y = unit(2, "pt"))
)
```

```{r}
figure_1B <- CFU_plot_34 +
  theme(text = element_text(size = 12),
        plot.margin = unit(c(0.1, 0.1, 0.1, 0.1), "in"))

figure_1C <- LDH_plot_34 +
  theme(text = element_text(size = 12), 
        plot.margin = unit(c(0.1, 0.1, 0.1, 0.1), "in"),
        legend.position = "none")

figure_1 <- ggarrange(figure_1B, figure1_legend, figure_1C, nrow = 1, widths = c(1, 0.2, 0.6))
figure_1

# Save figure 
ggsave(plot = figure_1, filename = file.path(figures_folder, "figure_1.png"), width = unit(7.5, "in"), height = unit(3, "in"))
ggsave(plot = figure_1, filename = file.path(figures_folder, "figure_1.svg"), width = unit(7.5, "in"), height = unit(3, "in"))
```

### Figure S1

```{r}
figureS1_legendA <- get_legend(PCA_plot + 
                       theme(text = element_text(size = 14),
                             legend.key.size = unit(10,"pt"),
                             legend.key.spacing.y = unit(0, "pt"),
                             legend.spacing.y = unit(2, "pt"))
)

figureS1_legendB <- get_legend(LDH_plot_37 + 
                       theme(text = element_text(size = 14),
                             legend.key.size = unit(10,"pt"),
                             legend.key.spacing.y = unit(0, "pt"),
                             legend.spacing.y = unit(2, "pt"))
)
#figureS1_legend <- ggarrange(p.empty, figureS1_legendA, figureS1_legendB, p.empty, ncol = 1, heights = c(1, 0.2, 0.8, 1))
figureS1_legend <- ggarrange(p.empty, figureS1_legendA, figureS1_legendB, p.empty, ncol = 1, heights = c(0.2, 0.2, 0.8, 0.2))
```

```{r}
figure_1SA <- PCA_plot +
  theme(text = element_text(size = 14), 
        plot.margin = unit(c(0.2, 0.2, 0.1, 0.1), "in"),
        legend.position = "none") 

figure_1SB <- MOC_Cplot +
  theme(text = element_text(size = 14), 
        plot.margin = unit(c(0.2, 0.1, 0.1, 0.05), "in"),
        legend.position = "none")

figure_1SC <- CFU_plot_37 +
  theme(text = element_text(size = 14),
        plot.margin = unit(c(0.2, 0.2, 0.1, 0.1), "in"))

figure_1SD <- LDH_plot_37 +
  theme(text = element_text(size = 14),
        plot.margin = unit(c(0.2, 0.1, 0.1, 0.1), "in"),
        legend.position = "none")

figure_1Sup <- ggarrange(figure_1SA, figure_1SB, figureS1_legend, labels = c("A", "B", ""), vjust = 1.3, nrow = 1, widths = c(1, 1, 0.4))
figure_1Sdown <- ggarrange(figure_1SC, figure_1SD, labels = c("C", "D"), vjust = 1.3, nrow = 1, widths = c(1, 0.6))

figure_1S <- ggarrange(figure_1Sup, figure_1Sdown, ncol = 1)
#figure_1S <- ggarrange(figureS1_legend, figure_1S, widths = c(0.2, 1))
figure_1S

# Save figure 
ggsave(plot = figure_1S, filename = file.path(figures_folder, "figure_S1.png"), width = unit(10.5, "in"), height = unit(8.5, "in"))
ggsave(plot = figure_1S, filename = file.path(figures_folder, "figure_S1.svg"), width = unit(10.5, "in"), height = unit(8.5, "in"))
```


### Figure S2

```{r}
figureS2_legend <- get_legend(HekBlue_A + 
                       theme(text = element_text(size = 14),
                             legend.key.size = unit(10,"pt"),
                             legend.key.spacing.y = unit(2, "pt"),
                             legend.spacing.y = unit(2, "pt"))
)
```

```{r}
figure_2SB <- HekBlue_A +
  theme(text = element_text(size = 16),
        plot.margin = unit(c(-0.2, 0.1, 0.1, 0.1), "in"),
        legend.position = "none")

figure_2SC <- HekBlue_B +
  theme(text = element_text(size = 16), 
        plot.margin = unit(c(-0.2, 0.1, 0.1, 0.1), "in"),
        legend.position = "none")

figure_2SC <- ggarrange(figure_2SB, figure_2SC, figureS2_legend, nrow = 1, labels = c("B", "C", ""), widths = c(1, 1, 0.3), vjust = -1)
figure_2SC <- ggarrange(Heatmap, figure_2SC, ncol = 1, labels = c("A", ""))
figure_2SC

# Save figure 
ggsave(plot = figure_2SC, filename = file.path(figures_folder, "figure_S2.png"), width = unit(11, "in"), height = unit(8.5, "in"))
ggsave(plot = figure_2SC, filename = file.path(figures_folder, "figure_S2.svg"), width = unit(11, "in"), height = unit(8.5, "in"))
```

### Figure 2

```{r}
filter_plots <- function(list, contrasts, selected, ymin, ymax, rows, cols, widths) {
  sublist <- list() 
  plot_counter <- 1  # Initialize plot counter
  
  for (group in selected) {
    if (group == "LEGEND") {
        sublist <- c(sublist, list(figureS2_legend))  # Add the legend plot
        plot_counter <- plot_counter + 1  # Increment plot counter
      next  # Skip to the next group in the selected list
    }
    
    for (element in list) {
      if (element[[1]] == group) {
        # Change size of the geom_jitter for all plots
        element[[2]]$layers[[1]]$aes_params$size <- 1
        
        contrast_sign <- contrasts %>%
          filter(group_label == group) %>%
          filter(sign.FDR == TRUE & highlighted != "") %>%
          mutate(plot = "")
        
        # Extract the part of the string before the underscore for the plot title
        plot_title <- gsub("_.*$", "", group)
        
        # Common plot customizations
        plot_customization <- element[[2]] +
          theme(axis.ticks = element_blank(),
                axis.title.y = element_text(size = 12),
                legend.position = "none",
                text = element_text(size = 14),
                plot.title = element_text(size = 12))
        
        # Customization for plots on the last row
        if (plot_counter > (rows - 1) * cols) {
          plot_customization <- plot_customization +
            scale_x_discrete(labels = c("U", "", "Live", "", "", "Dead", "")) + 
            ggtitle(NULL) + 
            labs(y = "pg/mL (basal)") 
        } else {
          plot_customization <- plot_customization +
            scale_x_discrete(breaks = NULL, labels = NULL) +
            ggtitle(plot_title) + 
            labs(y = "pg/mL (apical)") 
        } 
        
        # Customization for plots on the first column
        if ((plot_counter - 1) %% cols == 0) {
          plot_customization <- plot_customization +
            scale_y_log10(limits = c(ymin, ymax),
                          breaks = trans_breaks("log10", function(x) 10^x),
                          labels = trans_format("log10", math_format(10^.x))) +
            theme(plot.margin = unit(c(0, 0.05, -0.1, 0.1), "in"))
        } else {
          plot_customization <- plot_customization +
            scale_y_log10(limits = c(ymin, ymax), breaks = NULL, labels = NULL) +
            labs(y = "") +
            theme(plot.margin = unit(c(0, 0.05, -0.1, -0.15), "in"))
        }
        
        # Conditionally add p-value annotations layer
        if (nrow(contrast_sign) > 0) {
          plot_customization <- plot_customization +
            stat_pvalue_manual(contrast_sign, label = "plot", y.position = log10(ymax) - 0.01, 
                               step.increase = -0.03, tip.length = 0, bracket.shorten = 0.2, vjust = 0.6)
        }
        
        # Add the customized plot to the sublist
        sublist <- c(sublist, list(plot_customization))
        
        plot_counter <- plot_counter + 1  # Increment plot counter
        break  # Exit the loop once the desired group is found
      }
    }
  }
  
  figure <- ggarrange(plotlist = sublist, nrow = rows, ncol = cols, widths = widths)
  
  return(figure)
}
```

```{r}
#| message: FALSE
groups_2A <- c("IL-1α_Apical", "IL-1RN_Apical", "IL-18_Apical", "IL-1α_Basal", "IL-1RN_Basal", "IL-18_Basal")
figure_2A <- filter_plots(Cyto_plots_list, Cyto_contrasts, groups_2A, ymin = 0.2, ymax = 10^4.25, rows = 2, cols = 3, widths = c(1.46, 1, 1))
figure_2A

groups_2B <- c("CXCL-10_Apical", "CXCL-11_Apical", "CXCL-10_Basal", "LEGEND")
figure_2B <- filter_plots(Cyto_plots_list, Cyto_contrasts, groups_2B, ymin = 0.5, ymax = 10^3.2, rows = 2, cols = 2, widths = c(1.46, 1))
figure_2B

groups_2C <- c("G-CSF_Apical", "CCL-20_Apical", "G-CSF_Basal", "CCL-20_Basal")
figure_2C <- filter_plots(Cyto_plots_list, Cyto_contrasts, groups_2C, ymin = 1, ymax = 10^5.5, rows = 2, cols = 2, widths = c(1.46, 1))
figure_2C

groups_2D <- c("TNF-α_Apical", "IL-6_Apical", "IL-8_Apical", "TNF-α_Basal", "IL-6_Basal", "IL-8_Basal")
figure_2D <- filter_plots(Cyto_plots_list, Cyto_contrasts, groups_2D, ymin = 0.25, ymax = 10^5, rows = 2, cols = 3, widths = c(1.46, 1, 1))
figure_2D

figure_2up <- ggarrange(figure_2A, figure_2B, labels = c("A", "B"), widths = c(2, 1.44), hjust = -1.3, vjust = 1.1)
figure_2up               

figure_2down <- ggarrange(figure_2C, figure_2D, labels = c("C", "D"), widths = c(1.44, 2), hjust = -1.3, vjust = 1.1)
figure_2down 

figure_2 <- ggarrange(p.empty, figure_2up, p.empty, figure_2down, nrow = 4, heights = c(0.02, 1, 0.01, 1))
figure_2

# Save figure 
ggsave(plot = figure_2, filename = file.path(figures_folder, "figure_2.png"), width = unit(7, "in"), height = unit(9, "in"))
ggsave(plot = figure_2, filename = file.path(figures_folder, "figure_2.svg"), width = unit(7, "in"), height = unit(9, "in"))
```



## Other code

Code to make the legend from scratch 
```{r}
df_legend <- tibble(
  label = c(
    "<b><span style='color:#5b5b5b;'>Uncol</span></b>",
    "<b><i><span style='color:#0443DC;'>Dpi</span></i>",
    "<b><i><span style='color:#6D05A0;'>Sau</span></i>", 
    "<b><i><span style='color:#928AB9;'>Spn</span></i>"
  ),
  x = c(.1, .1, .1, .1),
  y = c(.4, .3, .2, .1),
  color = c("white", "white", "white", "white"),
  fill = c("white","white", "white", "white")
)

p.legend <-  ggplot(df_legend) +
  aes(x, y, label = label, color = color, fill = fill) +
  geom_textbox(width = unit(.8, "in")) +  
  scale_color_identity() +
  scale_fill_identity() +
  xlim(0, .2) + ylim(.1, .4) +
  theme_void() +
  theme(plot.margin = unit(c(0,-5,.2,-5), "in"),
        plot.background = element_rect(fill = "white", color = "white"))

p.legend
```